package com.springbootbase.springbootproject.controller;


import com.springbootbase.springbootproject.pojo.ListResponse;
import com.springbootbase.springbootproject.pojo.Result;
import com.springbootbase.springbootproject.pojo.Student;
import com.springbootbase.springbootproject.pojo.Teacher;
import com.springbootbase.springbootproject.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/teacher")
public class teacherController {

    @Autowired
    private TeacherService teacherService;


    @GetMapping("/getTeacherInfo")
    public Result<Teacher> getTeacherInfo(Long id){
        Teacher teacher = teacherService.getInfoById(id);
        return  Result.success(teacher);
    }

    @PostMapping("/updateTeacherInfo")
    public Result updateTeacher(@RequestBody @Validated Teacher teacher){
        teacherService.updateTeacher(teacher);
        return Result.success();
    }
    @GetMapping("/getList")
    public Result getList(Long id,int pageSize,int pageNum){
        ListResponse teacherArrayList = teacherService.getList(id,pageSize,pageNum);
        return Result.success(teacherArrayList);
    }
}
